<template>
    <div>
      <!--树形列表-->
      <el-tree :data="data"
               :props="defaultProps"
               default-expanded-keys
               @node-click="handleNodeClick"
               default-expand-all
               current-node-key
               style="overflow:auto;height: 600px" indent="30" >
      </el-tree>
     <!-- <el-container>
        <el-aside width="200px">
          <el-menu
            default-active="2"
            router
            class="el-menu-vertical-demo"
            @open="handleOpen"
            @close="handleClose"
            background-color="">
            <el-submenu index="">
              <template slot="title">
                <i class="el-icon-location"></i>
                <span>镇党委</span>
              </template>
              <el-menu-item-group>
                <el-menu-item index="/index/BasicManagement/dd">光辉村党支部</el-menu-item>
              </el-menu-item-group>
              <el-submenu index="1-4">
                <template slot="title">中兴社区党委</template>
                <el-menu-item index="1-4-1">中兴社区一支部</el-menu-item>
                <el-menu-item index="1-4-2">中兴社区二支部</el-menu-item>
              </el-submenu>
              <el-menu-item-group>
                <el-menu-item index="1-1">中兴社区三支部</el-menu-item>
              </el-menu-item-group>
              <el-submenu index="1-4">
                <template slot="title">和平村党总支</template>
                <el-menu-item index="1-4-1">和平村党一支部</el-menu-item>
                <el-menu-item index="1-4-2">和平村党二支部</el-menu-item>
                <el-menu-item index="1-4-2">和平村党三支部</el-menu-item>
              </el-submenu>
            </el-submenu>
          </el-menu>
        </el-aside>
        <el-main><router-view></router-view></el-main>
      </el-container>-->
    </div>
</template>
<script>
import bus from '../bus.js'
  export default {

    data() {
      return {
        hellofind:'',
      sosaa:'',
        sosbb:'',
      list:[],
        data: [{
          depId:0,
          label: '镇党委',
          children: [{
            depId:1,
            label: '光辉村党支部',
            children: [{
              depId:2,
              label: '中兴社区一支部'
            },
              {label: '中兴社区二支部'
            }]
          },
            {label: '和平村党总支' ,
              children: [{
                label: '和平村一支部'
              },
                {
                    label:'和平村二支部'
                }
              ]
            },
          ]
        },

        ],
        defaultProps: {
          children: 'children',
          label: 'label',
          depId:'depId',

        },

      /*  handleNodeClick(data, node, vuecomponent) {
        /!*  this.$refs.tree.getCheckedKeys().concat(this.$refs.tree.getHalfCheckedKeys());*!/
          console.log('data:',  data,'\n' ,'node:', node, '\n', 'vuecomponent',vuecomponent);

          /!*拿到当前节点的名字*!/
         var niuname = node.label;
          /!*拿到当前父点节点的名字*!/
         var  niunum = node.parent.label;
          console.log('niuname',niuname);
          console.log('niunum',niunum);
          this.sosbb=niuname;
          /!*console.log(this.$refs.tree.getCheckedKeys());*!/
          /!*父节点的等级*!/


          /!*通过数据困查询该等级的所有节点，判断childNodes下的lable查看是否与其匹配,获得父节点名字*!/
         /!* var fathername=panduan(niunum);
          /!*根据当前节点的名字从后台获取整体信息*!/
          var allziliao = geiwoba(niuname);*!/

          /!*先把名字赋值给那边*!/
          this.$emit('childByValue', this.sosbb);
          console.log('niuname',niuname);
          console.log('niunum',niunum);
        }*/

      };
    },
    methods: {
      handleNodeClick(data, node, vuecomponent) {
        /*  this.$refs.tree.getCheckedKeys().concat(this.$refs.tree.getHalfCheckedKeys());*/
        console.log('data:',  data,'\n' ,'node:', node, '\n', 'vuecomponent',vuecomponent);

        /*拿到当前节点的名字*/
        var niuname = node.label;
        /*拿到当前父点节点的名字*/
        var  niunum = node.parent.label;
        console.log('niuname',niuname);
        console.log('niunum',niunum);
        this.sosaa=niuname;
        this.sosbb=niunum;
        /*console.log(this.$refs.tree.getCheckedKeys());*/
        /*父节点的等级*/

        /*通过数据困查询该等级的所有节点，判断childNodes下的lable查看是否与其匹配,获得父节点名字*/
        /* var fathername=panduan(niunum);
         /!*根据当前节点的名字从后台获取整体信息*!/
         var allziliao = geiwoba(niuname);*/

        /*先把名字赋值给那边*/
        this.$emit('childByValue',this.sosaa,this.sosbb);
        console.log('niuname',niuname);
        console.log('niunum',niunum);
      },
      /*通过数据困查询该等级的所有节点，判断childNodes下的lable查看是否与其匹配,获得父节点名字*/
      panduan(niunum){
        this.$http.get(地址).then((response)=>{
            if(response.level==niunum){
                if(this.childNodes==niuname){
                    return this.node.label;
                }
            }
        })

      },
      /*根据当前节点的名字从后台获取整体信息*/
      geiwoba(niuname){
        this.$http.get(地址).then((response)=>{

        })
      },

      /*获取树图*/
      geitree(){
        this.$http.get(地址).then((response)=>{
          this.data=response.data;
        })
      },
      /*getCheckedKeys(){ console.log(this.$refs.tree.getCheckedKeys()); },*/
    /*  handleNodeClick(data) {
        console.log(data);
      },*/
    /*  handleNodeClick(data, node, vuecomponent) {
        console.log('data:',  data,'\n' ,'node:', node, '\n', 'vuecomponent',vuecomponent);
        //首先将党组织名称和上级组织赋给表单
        var niname = node.label;
        var niunum = node.level;
        console.log('niuname',niname);
        console.log('niuname',niunum);
      },*/
      zxcna(){

      },

      getback(){
        /*console.log(getCurrentnode);  */
        current-node-key.getCurrentNode();
      },
    },
    mounted(){ //请求数据,操作dom，放在这个位置 mounted
      geitree();
    },
    /*判断有无返回值*/
   /* getback(){
        /!*console.log(getCurrentnode);  *!/
        return getCurrentnode;
    },*/
  /*  addtreeadd(){
        getCurrentNode()
    }*/
   /* props:{
        type:getCheckedKeys
    }*/

  };
</script>
<style lang="postcss" scoped>
    body {

    }


</style>
